package com.wl.designpattern.singleton;

/**
 * 优点：懒加载，线程安全，推荐使用
 *
 * Created by wangliang on 2021/2/27.
 */
public class Singleton {
    private Singleton() { }

    public static Singleton getInstance() {
        //第一次调用getInstance方法时才加载SingletonHolder并初始化sInstance
        return SingletonHolder.sInstance;
    }
    private static class SingletonHolder {
        private static final Singleton sInstance = new Singleton();
    }
}
